package com.ruoyi.tiktok.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.tiktok.domain.TFile;
import com.ruoyi.tiktok.mapper.TFileMapper;
import com.ruoyi.tiktok.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * fileUploadService业务层处理
 * 
 * @author admin
 * @date 2024-08-22
 */
@Service
public class TIFileService extends ServiceImpl<TFileMapper<?>, TFile> implements IFileService
{
    @Autowired
    private TFileMapper tFileMapper;

    /**
     * 查询fileUpload
     * 
     * @param id fileUpload主键
     * @return fileUpload
     */

    public TFile selectTFileById(Long id)
    {
        return tFileMapper.selectTFileById(id);
    }

    /**
     * 查询fileUpload列表
     * 
     * @param tFile fileUpload
     * @return fileUpload
     */

    public List<TFile> selectTFileList(TFile tFile)
    {
        return tFileMapper.selectTFileList(tFile);
    }

    /**
     * 查询fileUpload列表
     *
     * @return fileUpload
     */
    public List<TFile> selectTFileListByFolderId(String folderId)
    {
        TFile tFile = new TFile();
        tFile.setFileId(Long.valueOf(folderId));
        return tFileMapper.selectTFileList(tFile);
    }


    public int addList(List<TFile> list){
        int index=0;
        for (int i = 0; i < list.size(); i++) {
            index += insertTFile(list.get(i));
        }
        return index;
    }

    public int insertTFile(TFile tFile)
    {
        if(tFile.getCreateTime() == null){
            tFile.setCreateTime(DateUtils.getNowDate());
        }
        return tFileMapper.insertTFile(tFile);
    }

    /**
     * 修改fileUpload
     * 
     * @param tFile fileUpload
     * @return 结果
     */

    public int updateTFile(TFile tFile)
    {
        return tFileMapper.updateTFile(tFile);
    }

    /**
     * 批量删除fileUpload
     * 
     * @param ids 需要删除的fileUpload主键
     * @return 结果
     */
    public int deleteTFileByIds(Long[] ids)
    {
        return tFileMapper.deleteTFileByIds(ids);
    }

    /**
     * 删除fileUpload信息
     * 
     * @param id fileUpload主键
     * @return 结果
     */
    public int deleteTFileById(Long id)
    {
        return tFileMapper.deleteTFileById(id);
    }
}
